#include "GMWindows.h"


namespace app
{

GMWindows::GMWindows( void )
{
	m_hWnd = 0;
	m_hInstance = 0;
	m_wndproc = 0;
	memset( m_title, 0, sizeof( m_title ) );
	m_pos.x = m_pos.y = 0;
	m_size.x = m_size.y = 0;
}


GMWindows::~GMWindows( void )
{
	destroy();
}


bool GMWindows::initialize( void )
{
	WNDCLASS WndClass;
 
	WndClass.cbClsExtra = 0;
	WndClass.cbWndExtra = 0;
	WndClass.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
	WndClass.hCursor = LoadCursor( 0, IDC_ARROW );
	WndClass.hIcon = LoadIcon( 0, IDI_APPLICATION );
	WndClass.hInstance = hInstance();
	WndClass.lpfnWndProc = m_wndproc;
	WndClass.lpszClassName = title();
	WndClass.lpszMenuName = 0;
	WndClass.style = CS_HREDRAW | CS_VREDRAW;

	RegisterClass( &WndClass );
 

	m_hWnd = CreateWindow( title(), title(), 
						   WS_OVERLAPPEDWINDOW, 
						   pos().x, pos().y, 
						   size().x, size().y, 
						   0,
						   (HMENU)0,
						   hInstance(),
						   0 );

	ShowWindow( hWnd(), 1 );


	return true;
}


void GMWindows::destroy_windows( void )
{
	DestroyWindow( m_hWnd );
}


void GMWindows::destroy( void )
{
	UnregisterClass( title(), GetModuleHandle( 0 ) );
}

};